package homework7.soso.menu;

import homework7.soso.entity.MobileCard;
import homework7.soso.untils.CardUtil;

import java.util.Scanner;

public class AppMain {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        CardUtil cardUtil = new CardUtil();//工具对象
        SosoMenu sosoMgr = new SosoMenu();  //二级菜单
        do {
            System.out.println("*********欢迎使用嗖嗖移动业务大厅********");
            System.out.println("1.用户登录");
            System.out.println("2.用户注册");
            System.out.println("3.使用嗖嗖");
            System.out.println("4.话费充值");
            System.out.println("5.资费说明");
            System.out.println("6.退出系统");
            int number;
            do {        //验证输入的值是否合法
                if (input.hasNextInt()) {
                    number  = input.nextInt();
                    if (number<7&&number>=0) {
                        break;
                    }
                    else {
                        System.out.println("您的输入有误，请重新输入");
                        input.next();
                    }
                }
                else {
                    System.out.println("您的输入有误，请重新输入");
                    input.next();
                }
            } while (true);

            switch (number) {
                case 1://登录功能
                    System.out.println("请输入您的卡号");
                    String numbers = input.next();
                    System.out.println("请输入您的密码");
                    String passWord = input.next();
                    if (cardUtil.isExistCard(numbers, passWord)) {
                        sosoMgr.cardMenu(cardUtil,numbers);
                        break;
                    }else {
                        break;
                    }

                    //break;
                case 2:
                    MobileCard card = new MobileCard();
                    cardUtil.addCard(card);
                    break;
                case 3://使用嗖嗖
                    System.out.println("请输入您的卡号");
                    String numbers1 = input.next();
                    if (cardUtil.isExistCard(numbers1)) {
                        cardUtil.useSoso(numbers1);
                    }
                    break;
                case 4://充值金额
                    System.out.println("请输入充值卡号");
                    String numbers3 = input.next();
                    cardUtil.chargeMoney(numbers3);
                    break;
                case 5://资费说明
                    cardUtil.showDescription();
                    break;

                case 6:
                    cardUtil.exit();
                    System.out.println("欢迎再次使用，再见！");
                    System.exit(0);
                    break;
                default:
                    break;
            }
        } while (true);

    }
}
